<?php
	$title = "iPhotos: Marist College";
	$keyword = "iphotos";
	$description = "Digital photos from Marist College.";
    $head_code = "includes/head_code.inc";
	$stylesheet = "includes/index.css";
	$style = "marist-full";
	require($_SERVER['WEB_UTILS']);
	// Connect to Content Manager
	require_once("includes/CMBGenericWebService.php");
	$service = new CMBGenericWebService("db28cm", "cmjphp", "php1read");
	gen_head();
?> 

<div class="automargin" style="width: 90%;">

<h1 class="center">iPhotos - Marist Digital Photos</h1>

<div class="center">
    <form method="post" action="">
    <div>
        <input type="hidden" name="action" value="search" />
        <input type="text" name="value" value="<?php if(isset($_POST['value'])) { echo $_POST['value']; } ?>" style="padding: 6px; font-size: 16px; margin: 10px;" size="40" />
        <input type="submit" value="Search" style="padding: 4px; font-size: 18px; margin: 10px;" />
        <?php if(!isset($_GET['advanced'])) { ?><a href="?advanced=yes">Advanced search</a><?php } else { ?> <a href="index.html">Basic search</a><?php } ?><br />
        <table style="text-align: left; margin: auto;" cellpadding="3">
        <?php if(isset($_GET['advanced'])) { ?>
        <tr>
        <th>Search type:</th>
        <td>
        <?php 
        	if(isset($_POST['type'])) {
            	switch($_POST['type']) {
                	case "Keyword":
                    	$keyphrase = "selected=\"selected\"";
                        break;
                    case "LIBDate":
                        $date = "selected=\"selected\"";
                        break;
                    case "Department":
                        $department = "selected=\"selected\"";
                        break;
                    case "Image":
                        $filename = "selected=\"selected\"";
                        break;
                    case "Author01":
                    	$photographer = "selected=\"selected\"";
                        break;
                    case "Rating":
                    	$rating = "selected=\"selected\"";
                        break;
                    default:
                    	$keyphrase = "selected=\"selected\"";
                        break;
               	}
            }
        ?>
        <select name="type">
        	<option value="Keyword" <?php echo $keyphrase; ?>>Keyword</option>
        	<option value="LIBDate" <?php echo $date; ?>>Date</option>
            <option value="Department" <?php echo $department; ?>>Department</option>
            <option value="Image" <?php echo $filename; ?>>Filename</option>
			<option value="Author01" <?php echo $photographer; ?>>Photographer</option>
            <option value="Rating" <?php echo $rating; ?>>Rating</option>
        </select> 
        </td>
        </tr>
        <?php } ?>
    	<tr>
        <th>Results:</th>
        <td>
        <?php 
        	if(isset($_POST['results'])) {
            	switch($_POST['results']) {
                	case "10":
                    	$ten = "selected=\"selected\"";
                        break;
                    case "25":
                        $twentyfive = "selected=\"selected\"";
                        break;
                    case "50":
                        $fifty = "selected=\"selected\"";
                        break;
                    case "100":
                        $hundred = "selected=\"selected\"";
                        break;
                    case "0":
                    	$all = "selected=\"selected\"";
                        break;
                    default:
                    	$ten = "selected=\"selected\"";
                        break;
               	}
            }
        ?>
        <select name="results">
        	<option value="10" <?php echo $ten; ?>>10</option>
        	<option value="25" <?php echo $twentyfive; ?>>25</option>
            <option value="50" <?php echo $fifty; ?>>50</option>
            <option value="100" <?php echo $hundred; ?>>100</option>
			<option value="0" <?php echo $all; ?>>All</option>
        </select>
        </td>
        </tr>
        </table>
    </div>
    </form>
</div>

<hr />

<div id="search" style="width: 100%; text-align: center;"><img src="fancybox/loading-spinner.gif" alt="loading" style="border: none; margin-top: 100px;" /></div>

</div>

<script type="text/javascript">

jQuery(document).ready(function() {
	jQuery.ajax({
		type: "POST",
  		url: "search.html",
		data: jQuery(":input").serialize(),
  		success: function(data) {
    		jQuery('#search').html(data);
  		}
	});							
});
</script>

<?php
        gen_foot();
?>
